home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / lib2to3 / fixes / fix_throw.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  2.0 KB  |  32 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Fixer for generator.throw(E, V, T).
  5.  
  6. g.throw(E)       -> g.throw(E)
  7. g.throw(E, V)    -> g.throw(E(V))
  8. g.throw(E, V, T) -> g.throw(E(V).with_traceback(T))
  9.  
  10. g.throw("foo"[, V[, T]]) will warn about string exceptions.'''
  11. from  import pytree
  12. from pgen2 import token
  13. from  import fixer_base
  14. from fixer_util import Name, Call, ArgList, Attr, is_tuple
  15.  
  16. class FixThrow(fixer_base.BaseFix):
  17.     PATTERN = "\n    power< any trailer< '.' 'throw' >\n           trailer< '(' args=arglist< exc=any ',' val=any [',' tb=any] > ')' >\n    >\n    |\n    power< any trailer< '.' 'throw' > trailer< '(' exc=any ')' > >\n    "
  18.     
  19.     def transform(self, node, results):
  20.         syms = self.syms
  21.         exc = results['exc'].clone()
  22.         if exc.type is token.STRING:
  23.             self.cannot_convert(node, 'Python 3 does not support string exceptions')
  24.             return None
  25.         val = results.get('val')
  26.         if val is None:
  27.             return None
  28.         val = val.clone()
  29.         throw_args = results['args']
  30.  
  31.  
  32.